package com.ijolas.test;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import org.jsoup.examples.ListLinks;

public class MainWindow extends JFrame {

	private static final long serialVersionUID = 7865873807279709188L;
	JButton downloadButton;

	public MainWindow() {
		super();
		init();
	}

	public void init() {
		// Window properties
		this.setBounds(0, 0, 600, 480);
		this.setLayout(null);
		this.addWindowListener(new WindowListener() {

			@Override
			public void windowOpened(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowIconified(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeiconified(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowDeactivated(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowClosing(WindowEvent arg0) {
				System.exit(0);
			}

			@Override
			public void windowClosed(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}

			@Override
			public void windowActivated(WindowEvent arg0) {
				// TODO Auto-generated method stub

			}
		});

		// Download Button
		downloadButton = new JButton("Download");
		downloadButton.setBounds(10, 10, 100, 20);
		downloadButton.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				try {
					ListLinks.main(null);
				} // try
				catch (Exception e) {
					e.printStackTrace();
				} // catch
			}
		});
		;
		this.add(downloadButton);

	}

	public void start() {
		this.setVisible(true);
	}

}
